<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>while循环</title>
    <script>
        function funWhile(){
            var i = 1
            while (i<=20){
                console.log("第" + i + '次')
                i++
            }
        }
        function  funWhileAdd100(){
            var i = 1
            var sum = 0
            while(i<=100){
                sum += i
                i++
            }
            console.log(sum)
        }
        function funWhileAddEven(){
            var i=1
            var sum = 0
            while(i<=100){
                if (i%2==0){
                    sum += i
                }
                i++
            }
            console.log(sum)
        }
        function funContinue(){
            var i = 1
            while(i<=7){
                if(i==3){
                    i++
                    continue
                }
                console.log(i)
                i++
            }
            console.log('循环结束了')
        }
        function funBreak(){
            var i = 1
            while(i<=7){
                if(i==3){
                    break
                }
                console.log(i)
                i++
            }
            console.log('循环结束了')
        }
        function funX(){
            var i = 1
            while(i<=9){
                console.log("1x"+ i +"=" + i)
                i++
            }
        }
        function funXX(){
            var i = 1
            while(i<=9){
                var line = ''
                var j = 1
                while(j<=i){
                    line += j +"x"+ i +"=" + i*j + "  "
                    j++
                }
                console.log(line)
                i++
            }
        }
    </script>
</head>
<body>
    <button onclick="funWhile()">while循环</button>
    <button onclick="funWhileAdd100()">add循环</button>
    <button onclick="funWhileAddEven()">偶数add循环</button>
    <button onclick="funContinue()">跳过3</button>
    <button onclick="funBreak()">结束3</button>
    <button onclick="funX()">X</button>
    <button onclick="funXX()">乘法口诀</button>

</body>
</html>